CREATE    PROC SP_SAVE_AMKOR_LOT_EVENT_HISTROY (
    	@CUSTOMER_NO     	VARCHAR (10),         
	@CUSTOMER_NAME   	VARCHAR (25),         
	@FACTORY_ID      	VARCHAR (10),         
	@FACTORY_DESC    	VARCHAR (50),         
	@CURRENT_PLANT   	VARCHAR (10),         
	@BUSINESS_ID     	VARCHAR (10),         
	@CUST_LOT_ID     	VARCHAR (50),         
	@FACTORY_LOT_ID  	VARCHAR (50),         
	@SOURCE_DEVICE   	VARCHAR (50),         
	@TARGET_DEVICE   	VARCHAR (50),         
	@PDL_DESC        	VARCHAR (50),         
	@PACKAGE_DESC    	VARCHAR (50),         
	@PACKAGE_CODE    	VARCHAR (10),         
	@DIMENSION       	VARCHAR (10),         
	@LEAD_COUNT      	VARCHAR (10),         
	@DIEBANK_FLAG    	VARCHAR (10),         
	@WIP_OPERATION   	VARCHAR (10),         
	@WIP_OPERATION_DESC   	VARCHAR (50),   
	@LOT_HANDLING_CODE    	VARCHAR (10),    
	@LOT_PRIORITY_CODE    	VARCHAR (50),    
	@EVENT_TYPE      	VARCHAR (50),         
	@EVENT_DATE      	VARCHAR (50),              
	@EVENT_TIME      	VARCHAR (50),         
	@EVENT_QTY_WAFER 	VARCHAR (50),         
	@EVENT_QTY_DIE   	VARCHAR (50),         
	@RECEIPT_DATE    	VARCHAR (50),              
	@RECEIPT_QTY     	VARCHAR (50),        
	@SHIPTO_CODE     	VARCHAR (25),        
	@SHIP_TO_DESC1   	VARCHAR (50),        
	@SHIP_TO_DESC2   	VARCHAR (50),        
	@SHIP_TO_DESC3   	VARCHAR (50),        
	@SHIP_TO_DESC4   	VARCHAR (50),        
	@SHIP_TO_DESC5   	VARCHAR (50),        
	@SHIP_TO_DESC6   	VARCHAR (50),        
	@SHIP_TO_DESC7   	VARCHAR (50),        
	@SHIP_TO_DESC8   	VARCHAR (50),        
	@SHIP_TO_DESC9   	VARCHAR (50),        
	@COMMERCIAL_INVOICE_NO  VARCHAR (50), 
	@SHIPMENT_NO     	VARCHAR (50),         
	@CUST_PO_NO      	VARCHAR (50),         
	@PIN_NO          	VARCHAR (50),         
	@SID_NO          	VARCHAR (50),         
	@MATERIAL_TYPE   	VARCHAR (50),         
	@MATERIAL_CUSTOMER_NO   VARCHAR (50),  
	@MATERIAL_DESC   	VARCHAR (50),         
	@ORIG_PLANNED_SHIPBACK_DATE   VARCHAR (50), 
	@REV_PLANNED_SHIPBACK_DATE    VARCHAR (50), 
	@ORIG_PROJECTED_SHIPBACK_DATE VARCHAR (50), 
	@REV_PROJECTED_SHIPBACK_DATE  VARCHAR (50), 
	@DATE_CODE   		VARCHAR (50),
	@CURRENT_DATE		VARCHAR (10) )
        
	AS
        BEGIN
		DECLARE @DATE_TIME DATETIME
     		DECLARE @START_DATE DATETIME
     		DECLARE @END_DATE DATETIME
		DECLARE @TIME_STAMP DATETIME
     		DECLARE @TEMP_VARCHAR VARCHAR(20)
		
		SET @TEMP_VARCHAR = CONVERT(VARCHAR, CURRENT_TIMESTAMP, 101)+' 12:00AM'
     		SET @START_DATE = CONVERT(DATETIME, @TEMP_VARCHAR)
     		SET @TEMP_VARCHAR = NULL
     		SET @TEMP_VARCHAR = CONVERT(VARCHAR, CURRENT_TIMESTAMP, 101)+' 11:59PM' 
     		SET @END_DATE = CONVERT(DATETIME, @TEMP_VARCHAR)
						
		INSERT INTO AMKOR_LOT_EVENT_TABLE(CUSTOMER_NO,CUSTOMER_NAME,FACTORY_ID,FACTORY_DESC,CURRENT_PLANT,BUSINESS_ID,CUST_LOT_ID,FACTORY_LOT_ID,SOURCE_DEVICE,TARGET_DEVICE,PDL_DESC,PACKAGE_DESC,PACKAGE_CODE,DIMENSION,LEAD_COUNT,DIEBANK_FLAG,WIP_OPERATION,WIP_OPERATION_DESC,LOT_HANDLING_CODE,LOT_PRIORITY_CODE,		
				EVENT_TYPE,EVENT_DATE,EVENT_TIME,EVENT_QTY_WAFER,EVENT_QTY_DIE,RECEIPT_DATE,RECEIPT_QTY,SHIPTO_CODE,SHIP_TO_DESC1,SHIP_TO_DESC2,SHIP_TO_DESC3,SHIP_TO_DESC4,SHIP_TO_DESC5,SHIP_TO_DESC6,SHIP_TO_DESC7,SHIP_TO_DESC8,SHIP_TO_DESC9,COMMERCIAL_INVOICE_NO,SHIPMENT_NO,CUST_PO_NO,PIN_NO,SID_NO,MATERIAL_TYPE,
				MATERIAL_CUSTOMER_NO,MATERIAL_DESC,ORIG_PLANNED_SHIPBACK_DATE,REV_PLANNED_SHIPBACK_DATE,ORIG_PROJECTED_SHIPBACK_DATE,REV_PROJECTED_SHIPBACK_DATE,DATE_CODE,TIMESTAMP ) 		
				VALUES (@CUSTOMER_NO,@CUSTOMER_NAME,@FACTORY_ID,@FACTORY_DESC,@CURRENT_PLANT,@BUSINESS_ID,@CUST_LOT_ID,@FACTORY_LOT_ID,@SOURCE_DEVICE,@TARGET_DEVICE,@PDL_DESC,@PACKAGE_DESC,@PACKAGE_CODE,@DIMENSION,@LEAD_COUNT,@DIEBANK_FLAG,@WIP_OPERATION,@WIP_OPERATION_DESC,@LOT_HANDLING_CODE,@LOT_PRIORITY_CODE,		
				@EVENT_TYPE,@EVENT_DATE,@EVENT_TIME,@EVENT_QTY_WAFER,@EVENT_QTY_DIE,@RECEIPT_DATE,@RECEIPT_QTY,@SHIPTO_CODE,@SHIP_TO_DESC1,@SHIP_TO_DESC2,@SHIP_TO_DESC3,@SHIP_TO_DESC4,@SHIP_TO_DESC5,@SHIP_TO_DESC6,@SHIP_TO_DESC7,@SHIP_TO_DESC8,@SHIP_TO_DESC9,@COMMERCIAL_INVOICE_NO,@SHIPMENT_NO,@CUST_PO_NO,@PIN_NO,@SID_NO,@MATERIAL_TYPE,
				@MATERIAL_CUSTOMER_NO,@MATERIAL_DESC,@ORIG_PLANNED_SHIPBACK_DATE,@REV_PLANNED_SHIPBACK_DATE,@ORIG_PROJECTED_SHIPBACK_DATE,@REV_PROJECTED_SHIPBACK_DATE,@DATE_CODE,CURRENT_TIMESTAMP )
			
		INSERT INTO AMKOR_LOT_EVENT_HISTORY_TABLE(CUSTOMER_NO,CUSTOMER_NAME,FACTORY_ID,FACTORY_DESC,CURRENT_PLANT,BUSINESS_ID,CUST_LOT_ID,FACTORY_LOT_ID,SOURCE_DEVICE,TARGET_DEVICE,PDL_DESC,PACKAGE_DESC,PACKAGE_CODE,DIMENSION,LEAD_COUNT,DIEBANK_FLAG,WIP_OPERATION,WIP_OPERATION_DESC,LOT_HANDLING_CODE,LOT_PRIORITY_CODE,		
				EVENT_TYPE,EVENT_DATE,EVENT_TIME,EVENT_QTY_WAFER,EVENT_QTY_DIE,RECEIPT_DATE,RECEIPT_QTY,SHIPTO_CODE,SHIP_TO_DESC1,SHIP_TO_DESC2,SHIP_TO_DESC3,SHIP_TO_DESC4,SHIP_TO_DESC5,SHIP_TO_DESC6,SHIP_TO_DESC7,SHIP_TO_DESC8,SHIP_TO_DESC9,COMMERCIAL_INVOICE_NO,SHIPMENT_NO,CUST_PO_NO,PIN_NO,SID_NO,MATERIAL_TYPE,
				MATERIAL_CUSTOMER_NO,MATERIAL_DESC,ORIG_PLANNED_SHIPBACK_DATE,REV_PLANNED_SHIPBACK_DATE,ORIG_PROJECTED_SHIPBACK_DATE,REV_PROJECTED_SHIPBACK_DATE,DATE_CODE,ADAPTOR_DATE,TIMESTAMP ) 		
				VALUES (@CUSTOMER_NO,@CUSTOMER_NAME,@FACTORY_ID,@FACTORY_DESC,@CURRENT_PLANT,@BUSINESS_ID,@CUST_LOT_ID,@FACTORY_LOT_ID,@SOURCE_DEVICE,@TARGET_DEVICE,@PDL_DESC,@PACKAGE_DESC,@PACKAGE_CODE,@DIMENSION,@LEAD_COUNT,@DIEBANK_FLAG,@WIP_OPERATION,@WIP_OPERATION_DESC,@LOT_HANDLING_CODE,@LOT_PRIORITY_CODE,		
				@EVENT_TYPE,@EVENT_DATE,@EVENT_TIME,@EVENT_QTY_WAFER,@EVENT_QTY_DIE,@RECEIPT_DATE,@RECEIPT_QTY,@SHIPTO_CODE,@SHIP_TO_DESC1,@SHIP_TO_DESC2,@SHIP_TO_DESC3,@SHIP_TO_DESC4,@SHIP_TO_DESC5,@SHIP_TO_DESC6,@SHIP_TO_DESC7,@SHIP_TO_DESC8,@SHIP_TO_DESC9,@COMMERCIAL_INVOICE_NO,@SHIPMENT_NO,@CUST_PO_NO,@PIN_NO,@SID_NO,@MATERIAL_TYPE,
				@MATERIAL_CUSTOMER_NO,@MATERIAL_DESC,@ORIG_PLANNED_SHIPBACK_DATE,@REV_PLANNED_SHIPBACK_DATE,@ORIG_PROJECTED_SHIPBACK_DATE,@REV_PROJECTED_SHIPBACK_DATE,@DATE_CODE,@CURRENT_DATE,CURRENT_TIMESTAMP )
		
	END
